#!/user/bin/env python3
# -*- coding: utf-8 -*-
"""
--------------------------------------
    Author:     JiChao_Song
    Date  :     2021/11/28 15:31
    Desc  :
--------------------------------------
"""
import datetime

from django.http import JsonResponse

from common.enums import AbstractBaseCodeMessageEnum
from common.enums.response_enums import CommonResultEnums


class RPCCommonResponse():
    def __new__(cls, codeEnums: AbstractBaseCodeMessageEnum, result: any = None):
        return dict(
            code = codeEnums.code,
            message = codeEnums.message,
            result = result,
            systemTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
            type = 'success'
        )


class RPCSuccessResponse():
    def __new__(cls, codeEnums=CommonResultEnums.SUCCESS, result: any = None):
        return dict(
            code = codeEnums.code,
            message = codeEnums.message,
            result = result,
            systemTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
            type = 'success'
        )


class RPCParamsErrorResponse():
    def __new__(cls, message: str, code=40002, result=None):
        return dict(
            code = code,
            message = message,
            result = result,
            systemTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
            type = 'success'
        )


class RPCSystemExceptionResponse:

    def __new__(cls, codeEnums=CommonResultEnums.SYSTEM_EXCEPTION, result: any = None):
        return dict(
            code = codeEnums.code,
            message = codeEnums.message,
            result = result,
            systemTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
            type = 'error'
        )
